package com.ruoyi.training.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.examination.domain.ExamRecord;
import com.ruoyi.examination.domain.ExamRecordSpecial;
import com.ruoyi.examination.mapper.ExamRecordMapper;
import com.ruoyi.examination.mapper.ExamRecordSpecialMapper;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.training.domain.*;
import com.ruoyi.training.dto.MyCertificateInfo;
import com.ruoyi.training.dto.MyExamInfo;
import com.ruoyi.training.dto.MyGradeInfo;
import com.ruoyi.training.dto.SysUserDto;
import com.ruoyi.training.mapper.*;
import com.ruoyi.training.util.xuehua.SnowflakeIdUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.training.service.IStudentsService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 学员Service业务层处理
 *
 * @author ruoyi
 * @date 2025-09-16
 */
@Service
public class StudentsServiceImpl implements IStudentsService {
    @Autowired
    private StudentsMapper studentsMapper;

    @Autowired
    private UnitsMapper unitsMapper;

    @Autowired
    private ExamRecordMapper examRecordMapper;

    @Autowired
    private TrainingClassMapper trainingClassMapper;

    @Autowired
    private ExamRecordSpecialMapper examRecordSpecialMapper;

    @Autowired
    private CertificateIssueMapper certificateIssueMapper;

    @Autowired
    private SpecialCertificateMapper specialCertificateMapper;

    @Autowired
    private ProjectsMapper projectsMapper;

    /**
     * 查询学员
     *
     * @param studentId 学员主键
     * @return 学员
     */
    @Override
    public Students selectStudentsByStudentId(String studentId) {
        return studentsMapper.selectStudentsByStudentId(studentId);
    }

    /**
     * 查询学员列表
     *
     * @param students 学员
     * @return 学员
     */
    @Override
    public List<Students> selectStudentsList(Students students) {
        return studentsMapper.selectStudentsList(students);
    }

    /**
     * 新增学员
     *
     * @param students 学员
     * @return 结果
     */
    @Override
    public int insertStudents(Students students) {
        Students students1 = checkUserIdNumber(students.getStudentName());
        if (students1 != null) {
            //返回-1表示该证件号已存在，不能再次添加
            // return error("新增学员[" + students.getStudentName() + "-" + students.getIdNumber() + "]失败，该证件号已存在");
            return -1;
        }
        students.setStudentId(String.valueOf(new SnowflakeIdUtils(5, 8).nextId()));
        students.setIsTrace("0");
        students.setCreateTime(DateUtils.getNowDate());
        return studentsMapper.insertStudents(students);
    }

    /**
     * 修改学员
     *
     * @param students 学员
     * @return 结果
     */
    @Override
    public int updateStudents(Students students) {
        Students students1 = studentsMapper.selectStudentsByStudentId(students.getStudentId());
        //修改留痕，先将旧的数据状态修改为2（is_trace，del_flag），再将最新的数据新增一条学员信息
        //1.修改
        students1.setIsTrace("2");
        students1.setDelFlag("2");
        students.setUpdateTime(DateUtils.getNowDate());
        int updateStatus = studentsMapper.updateStudents(students1);
        //2.新增
        int insertStatus = insertStudents(students);
        if (insertStatus == -1) {
            students1.setIsTrace("0");
            students1.setDelFlag("0");
            students.setUpdateTime(null);
            studentsMapper.updateStudents(students1);
            return insertStatus;
        }
        return updateStatus;
    }

    /**
     * 批量删除学员
     *
     * @param studentIds 需要删除的学员主键
     * @return 结果
     */
    @Override
    public int deleteStudentsByStudentIds(String[] studentIds) {
        return studentsMapper.deleteStudentsByStudentIds(studentIds);
    }

    /**
     * 删除学员信息
     *
     * @param studentId 学员主键
     * @return 结果
     */
    @Override
    public int deleteStudentsByStudentId(String studentId) {
        return studentsMapper.deleteStudentsByStudentId(studentId);
    }

    /**
     * 通过证件号查询学员
     * lqx
     */
    @Override
    public Students checkUserIdNumber(String idNumber) {
        return studentsMapper.checkUserIdNumber(idNumber);
    }

    /**
     * 通过手机号查询学员
     * lqx
     */
    @Override
    public Students checkUserPhoneNumber(String phoneNumber) {
        return studentsMapper.checkUserPhoneNumber(phoneNumber);
    }

    /**
     * 通过ids查询学员信息
     * lqx
     */
    @Override
    public List<Students> selectStudentsByIds(List<String> studentIds) {
        return studentsMapper.selectStudentsByIds(studentIds);
    }

    @Override
    public List<Students> selectStudentsByStudentNoticeId(String studentNoticeId) {
        return studentsMapper.selectStudentsByStudentNoticeId((studentNoticeId));
    }

    /**
     * 查询内训用户列表
     * lqx
     */
    @Override
    public List<SysUserDto> selectUserList(SysUser sysUser) {
        List<SysUserDto> sysUserDtoList = new ArrayList<>();
        List<SysUser> sysUsers = studentsMapper.selectUserList(sysUser);
        for (SysUser sysUser1 : sysUsers) {
            SysUserDto sysUserDto = new SysUserDto();
            BeanUtils.copyProperties(sysUser1, sysUserDto);
            //查询单位名称
            if (!sysUserDto.getUnitId().isEmpty()) {
                Units units = unitsMapper.selectUnitsByUnitId(sysUserDto.getUnitId());
                sysUserDto.setUnitName(units.getUnitName());
            }
            sysUserDtoList.add(sysUserDto);
        }
        return sysUserDtoList;
    }

    /**
     * 新增学员-同步用户
     * lqx
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertStudentsWithUser(Students students) {
        //判断学员表中该证件号是否存在
        Students students1 = checkUserIdNumber(students.getIdNumber());
        if (students1 != null) {
            //判断是否删除
//            if ("2".equals(students1.getDelFlag())) {
//                //逻辑恢复
//                students.setStudentId(students1.getStudentId());
//                students.setIsTrace("0");
//                students.setDelFlag("0");
//                students.setCreateBy(SecurityUtils.getUsername());
//                students.setCreateTime(DateUtils.getNowDate());
//                BeanUtils.copyProperties(students, students1);
//                studentsMapper.updateStudents(students1);
//            } else {
                //返回-1表示该证件号已存在，不能再次添加
                // return error("新增学员[" + students.getStudentName() + "-" + students.getIdNumber() + "]失败，该证件号已存在");
                return -1;
//            }
        }
        //判断学员表手机号是否已被使用
        if (!students.getPhonenumber().isEmpty()) {
            Students students2 = checkUserPhoneNumber(students.getPhonenumber());
            if (students2 != null) {
                //返回-2表示该手机号已存在，不能再次添加
                return -2;
            }
        }
        students.setStudentId(String.valueOf(new SnowflakeIdUtils(5, 8).nextId()));
        students.setIsTrace("0");
        students.setDelFlag("0");
        students.setCreateBy(SecurityUtils.getUsername());
        students.setCreateTime(DateUtils.getNowDate());

        //新增用户
        //通过身份证号查询用户是否存在
        SysUser sysUser1 = studentsMapper.selectUserByIdNumber(students.getIdNumber());
        if (sysUser1 != null) {
            //判断是否被删除
//            if ("2".equals(sysUser1.getDelFlag())) {
//                //恢复用户
//                sysUser1.setDelFlag("0");
//                BeanUtils.copyProperties(students, sysUser1);
//                //同步姓名
//                if (!students.getStudentName().isEmpty()) {
//                    sysUser1.setNickName(students.getStudentName());
//                }
//                //同步人员类型
//                if (!students.getUserType().isEmpty()) {
//                    sysUser1.setExampleOne(students.getUserType());
//                }
//                //同步职务
//                if (!students.getPosition().isEmpty()) {
//                    sysUser1.setPositionRank(students.getPosition());
//                }
//                //修改用户状态
//                studentsMapper.updateUser(sysUser1);
//            }
            //判断是否被停用
            if ("1".equals(sysUser1.getStatus())) {
                //恢复用户
                sysUser1.setStatus("0");
                BeanUtils.copyProperties(students, sysUser1);
                //同步姓名
                if (!students.getStudentName().isEmpty()) {
                    sysUser1.setNickName(students.getStudentName());
                }
                //同步人员类型
                if (!students.getUserType().isEmpty()) {
                    sysUser1.setExampleOne(students.getUserType());
                }
                //同步职务
                if (!students.getPosition().isEmpty()) {
                    sysUser1.setPositionRank(students.getPosition());
                }
                //修改用户状态
                studentsMapper.updateUser(sysUser1);
            }
        } else {
            //同步用户信息
            SysUser sysUser = new SysUser();
            BeanUtils.copyProperties(students, sysUser);
            //同步姓名
            if (!students.getStudentName().isEmpty()) {
                sysUser.setNickName(students.getStudentName());
            }
            //同步人员类型
            if (!students.getUserType().isEmpty()) {
                sysUser.setExampleOne(students.getUserType());
            }
            //同步职务
            if (!students.getPosition().isEmpty()) {
                sysUser.setPositionRank(students.getPosition());
            }
            //设置用户的studentId
            sysUser.setStudentId(students.getStudentId());
            //设置默认的username手机号码
            sysUser.setUserName(students.getPhonenumber());
            //设置默认的密码123456
            sysUser.setPassword(SecurityUtils.encryptPassword("123456"));
            //新增用户
            studentsMapper.insertUser(sysUser);
        }
        //新增学员
        return studentsMapper.insertStudents(students);
    }

    /**
     * 修改学员-同步用户
     * lqx
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateStudentsWithUser(Students students) {
        //判断学员表中该证件号是否存在
        Students students1 = checkUserIdNumber(students.getIdNumber());
        if (students1 != null && !students.getStudentId().equals(students1.getStudentId())) {
            //返回-1表示该证件号已存在，不能再次添加
            return -1;
        }
        //判断学员表手机号是否已被使用
        if (!students.getPhonenumber().isEmpty()) {
            Students students2 = checkUserPhoneNumber(students.getPhonenumber());
            if (students2 != null && !students.getStudentId().equals(students1.getStudentId())) {
                //返回-2表示该手机号已存在，不能再次添加
                return -2;
            }
        }
        //同步用户
        //通过studentId查询出sysUser
        SysUser sysUser = studentsMapper.selectSysUserByStudentId(students.getStudentId());
        //同步用户信息
        BeanUtils.copyProperties(students, sysUser);
        //同步姓名
        if (!students.getStudentName().isEmpty()) {
            sysUser.setNickName(students.getStudentName());
        }
        //同步人员类型
        if (!students.getUserType().isEmpty()) {
            sysUser.setExampleOne(students.getUserType());
        }
        //同步职务
        if (!students.getPosition().isEmpty()) {
            sysUser.setPositionRank(students.getPosition());
        }
        //修改用户
        studentsMapper.updateUser(sysUser);

        //修改学员
        return studentsMapper.updateStudents(students);
    }

    /**
     * 删除学员-同步用户
     * lqx
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteStudentsWithUserByStudentIds(String[] studentIds) {
        //通过studentId查询user
        for (String studentId : studentIds) {
            SysUser sysUser = studentsMapper.selectSysUserByStudentId(studentId);
            if (sysUser != null){
                //同步删除
                SysUser sysUser1 = new SysUser();
                sysUser1.setUserId(sysUser.getUserId());
                sysUser1.setDelFlag("2");
                studentsMapper.updateUser(sysUser1);
            }
        }
        return studentsMapper.deleteStudentsByStudentIds(studentIds);
    }

    /**
     * 查询学员成绩
     * lqx
     */
    @Override
    public List<MyGradeInfo> getStudentGradeInfo(String studentId) {
        List<MyGradeInfo> myGradeInfoList = new ArrayList<>();
        //1.通过学员id查询经营性成绩
        List<ExamRecord> examRecordList = studentsMapper.selectExamListByStudentId(studentId);
        if (examRecordList != null && !examRecordList.isEmpty()){
            for (ExamRecord examRecord : examRecordList) {
                MyGradeInfo myGradeInfo = new MyGradeInfo();
                //设置试卷id
                if (!"".equals(examRecord.getExamPaperId()) && examRecord.getExamPaperId() != null){
                    myGradeInfo.setExamPaperId(examRecord.getExamPaperId());
                }
                //查询班级信息
                if (!"".equals(examRecord.getTrainingClassId()) && examRecord.getTrainingClassId() != null){
                    //设置班级id
                    myGradeInfo.setTrainingClassId(examRecord.getTrainingClassId());
                    TrainingClass trainingClass = trainingClassMapper.selectTrainingClassByTrainingClassId(examRecord.getTrainingClassId());
                    //设置班级编号
                    if (trainingClass.getTrainingClassCode() != null && !"".equals(trainingClass.getTrainingClassCode())){
                        myGradeInfo.setTrainingClassCode(trainingClass.getTrainingClassCode());
                    }
                    //设置班级名称
                    if (trainingClass.getTrainingClassName() != null && !"".equals(trainingClass.getTrainingClassName())){
                        myGradeInfo.setTrainingClassName(trainingClass.getTrainingClassName());
                    }
                    //设置培训类型
                    if (trainingClass.getSignUpCategory() != null && !"".equals(trainingClass.getSignUpCategory())){
                        myGradeInfo.setSignUpCategory(trainingClass.getSignUpCategory());
                    }
                }
                //设置培训项目
                if (!"".equals(examRecord.getTrainingProjectName()) && examRecord.getTrainingProjectName() != null){
                    myGradeInfo.setProjectName(examRecord.getTrainingProjectName());
                }
                //设置考试总分
                if (!"".equals(examRecord.getTotalScore()) && examRecord.getTotalScore() != null){
                    myGradeInfo.setTotalScore(examRecord.getTotalScore());
                }
                //设置理论成绩
                if (!"".equals(examRecord.getTheoryResult()) && examRecord.getTheoryResult() != null){
                    myGradeInfo.setTheoryResult(examRecord.getTheoryResult());
                }
                //设置实操成绩
                if (!"".equals(examRecord.getPracticalResult()) && examRecord.getPracticalResult() != null){
                    myGradeInfo.setPracticalResult(examRecord.getPracticalResult());
                }
                //设置补考成绩
                if (!"".equals(examRecord.getMakeUpResult()) && examRecord.getMakeUpResult() != null){
                    myGradeInfo.setMakeUpResult(examRecord.getMakeUpResult());
                }
                //设置考试结果
                if (!"".equals(examRecord.getExamResult()) && examRecord.getExamResult() != null){
                    myGradeInfo.setExamResult(examRecord.getExamResult());
                }
                //设置是否为补考
                if (!"".equals(examRecord.getMakeUpMark()) && examRecord.getMakeUpMark() != null){
                    myGradeInfo.setMakeUpMark(examRecord.getMakeUpMark());
                }
                //设置是否可补考
                if (!"".equals(examRecord.getMakeUpStatus()) && examRecord.getMakeUpStatus() != null){
                    myGradeInfo.setMakeUpStatus(examRecord.getMakeUpStatus());
                }
                myGradeInfoList.add(myGradeInfo);
            }
        }
        //2.通过学员id查询特设成绩
        List<ExamRecordSpecial> examRecordSpecialList = studentsMapper.selectExamSpecialListByStudentId(studentId);
        if (examRecordSpecialList != null && !examRecordSpecialList.isEmpty()){
            for (ExamRecordSpecial examRecordSpecial : examRecordSpecialList) {
                MyGradeInfo myGradeInfo = new MyGradeInfo();
                //查询班级信息
//                if (!"".equals(examRecordSpecial.getTrainingClassId()) && examRecordSpecial.getTrainingClassId() != null){
//                    TrainingClass trainingClass = trainingClassMapper.selectTrainingClassByTrainingClassId(examRecordSpecial.getTrainingClassId());
//                    //设置班级编号
//                    if (trainingClass.getTrainingClassCode() != null && !"".equals(trainingClass.getTrainingClassCode())){
//                        myGradeInfo.setTrainingClassCode(trainingClass.getTrainingClassCode());
//                    }
//                    //设置班级名称
//                    if (trainingClass.getTrainingClassName() != null && !"".equals(trainingClass.getTrainingClassName())){
//                        myGradeInfo.setTrainingClassName(trainingClass.getTrainingClassName());
//                    }
//                    //设置培训类型
//                    if (trainingClass.getSignUpCategory() != null && !"".equals(trainingClass.getSignUpCategory())){
//                        myGradeInfo.setSignUpCategory(trainingClass.getSignUpCategory());
//                    }
//                }
                //设置培训项目
//                if (!"".equals(examRecord.getTrainingProjectName()) && examRecord.getTrainingProjectName() != null){
//                    myGradeInfo.setProjectName(examRecord.getTrainingProjectName());
//                }
                //设置培训类型
                myGradeInfo.setSignUpCategory("special");
                //设置理论成绩
                if (!"".equals(examRecordSpecial.getTheoryResult()) && examRecordSpecial.getTheoryResult() != null){
                    myGradeInfo.setTheoryResult(examRecordSpecial.getTheoryResult());
                }
                //设置考试总分
                if (!"".equals(examRecordSpecial.getTotalScore()) && examRecordSpecial.getTotalScore() != null){
                    myGradeInfo.setTotalScore(examRecordSpecial.getTotalScore());
                }
                //设置实操成绩
                if (!"".equals(examRecordSpecial.getPracticalResult()) && examRecordSpecial.getPracticalResult() != null){
                    myGradeInfo.setPracticalResult(examRecordSpecial.getPracticalResult());
                }
                //设置补考成绩
                if (!"".equals(examRecordSpecial.getMakeUpResult()) && examRecordSpecial.getMakeUpResult() != null){
                    myGradeInfo.setMakeUpResult(examRecordSpecial.getMakeUpResult());
                }
                //设置考试结果
                if (!"".equals(examRecordSpecial.getExamResult()) && examRecordSpecial.getExamResult() != null){
                    myGradeInfo.setExamResult(examRecordSpecial.getExamResult());
                }
                //设置是否为补考
                if (!"".equals(examRecordSpecial.getMakeUpMark()) && examRecordSpecial.getMakeUpMark() != null){
                    myGradeInfo.setMakeUpMark(examRecordSpecial.getMakeUpMark());
                }
                //设置是否可补考
                if (!"".equals(examRecordSpecial.getMakeUpStatus()) && examRecordSpecial.getMakeUpStatus() != null){
                    myGradeInfo.setMakeUpStatus(examRecordSpecial.getMakeUpStatus());
                }
                myGradeInfoList.add(myGradeInfo);
            }
        }
        return myGradeInfoList;
    }

    /**
     * 查询学员证书
     * lqx
     */
    @Override
    public List<MyCertificateInfo> getStudentCertificateInfo(String studentId) {
        List<MyCertificateInfo> myCertificateInfoList = new ArrayList<>();
        //1.通过学员id查询经营性证书
        List<CertificateIssue> certificateIssueList = certificateIssueMapper.getByStudentId(studentId);
        System.out.println("certificateIssueList = " + certificateIssueList);
        if (!certificateIssueList.isEmpty() && certificateIssueList != null){
            for (CertificateIssue certificateIssue : certificateIssueList) {
                MyCertificateInfo myCertificateInfo = new MyCertificateInfo();
                //设置证书id
                myCertificateInfo.setCertificateId(certificateIssue.getCertificateIssueId());
                //设置证书状态  0-有效证书,1-过期证书,2-待发证书
                if (certificateIssue.getDigitalStatus() != null && !"".equals(certificateIssue.getDigitalStatus())){
                    //1-已生成，2-已撤销，3-未生成，4-已过期
                    if ("1".equals(certificateIssue.getDigitalStatus())){
                        myCertificateInfo.setCertificateStatus("0");
                    }else if ("4".equals(certificateIssue.getDigitalStatus())){
                        myCertificateInfo.setCertificateStatus("1");
                    }else {
                        myCertificateInfo.setCertificateStatus("2");
                    }
                }else {
                    myCertificateInfo.setCertificateStatus("0");
                }
                //设置证书类别-经营性
                myCertificateInfo.setCertificateCategory("regular");
                //设置证书类型
                if (certificateIssue.getCertificateType() != null && !"".equals(certificateIssue.getCertificateType())){
                    myCertificateInfo.setCertificateType(certificateIssue.getCertificateType());
                }
                //设置证书项目
                if (certificateIssue.getProjectId() != null && !"".equals(certificateIssue.getProjectId())){
                    Projects projects = projectsMapper.selectProjectsByProjectId(certificateIssue.getProjectId());
                    if (projects.getProjectName() != null && !"".equals(projects.getProjectName())){
                        myCertificateInfo.setProjectName(projects.getProjectName());
                    }
                }
                //设置证书编号
                if (certificateIssue.getCertificateIssueId() != null && !"".equals(certificateIssue.getCertificateIssueId())){
                    myCertificateInfo.setCertificateNo(certificateIssue.getCertificateIssueId());
                }
                //设置发证时间
                if (certificateIssue.getDigitalIssueTime() != null){
                    myCertificateInfo.setDigitalIssueTime(certificateIssue.getDigitalIssueTime());
                }
                //设置有效期起
                if (certificateIssue.getValidityStart() != null){
                    myCertificateInfo.setValidityStart(certificateIssue.getValidityStart());
                }
                //设置有效期止
                if (certificateIssue.getValidityEnd() != null){
                    myCertificateInfo.setValidityEnd(certificateIssue.getValidityEnd());
                }
                //设置纸质证书领取方式
                if (certificateIssue.getReceiveMethod() != null && !"".equals(certificateIssue.getReceiveMethod())){
                    myCertificateInfo.setReceiveMethod(certificateIssue.getReceiveMethod());
                }
                //设置快递单号
                if (certificateIssue.getTrackingNo() != null && !"".equals(certificateIssue.getTrackingNo())){
                    myCertificateInfo.setTrackingNo(certificateIssue.getTrackingNo());
                }
                myCertificateInfoList.add(myCertificateInfo);
            }
        }
        //2.通过学员id查询特设证书
        List<SpecialCertificate> specialCertificateList = specialCertificateMapper.getByStudentId(studentId);
        System.out.println("specialCertificateList = " + specialCertificateList);
        if (!specialCertificateList.isEmpty() && specialCertificateList != null){
            for (SpecialCertificate specialCertificate : specialCertificateList) {
                MyCertificateInfo myCertificateInfo = new MyCertificateInfo();
                //设置证书id
                myCertificateInfo.setCertificateId(specialCertificate.getSpecialCertificateId());
                //设置证书状态  0-有效证书,1-过期证书,2-待发证书
                Date currentTime = new Date();
                if (specialCertificate.getValidityStartTime() != null && specialCertificate.getValidityEndTime() != null){
                    Date startTime = specialCertificate.getValidityStartTime();
                    Date endTime = specialCertificate.getValidityEndTime();
                    // Date 类通过 compareTo() 方法比较时间：
                    // 1. 开始时间 <= 当前时间：startTime.compareTo(currentTime) <= 0
                    // 2. 当前时间 <= 结束时间：currentTime.compareTo(endTime) <= 0
                    boolean isWithinValidity = startTime.compareTo(currentTime) <= 0
                            && currentTime.compareTo(endTime) <= 0;

                    if (isWithinValidity) {
                        // 当前时间在有效期内（开始时间 <= 现在 <= 结束时间）
                        myCertificateInfo.setCertificateStatus("0");
                    } else {
                        // 当前时间不在有效期内（已过期或未生效）
                        myCertificateInfo.setCertificateStatus("1");
                    }
                }else {
                    myCertificateInfo.setCertificateStatus("0");
                }
                //设置证书类别-特设
                myCertificateInfo.setCertificateCategory("special");
                //设置证书类型
                if (specialCertificate.getCertificateType() != null && !"".equals(specialCertificate.getCertificateType())){
                    myCertificateInfo.setCertificateType(specialCertificate.getCertificateType());
                }
                //设置作业种类
                if (specialCertificate.getWorkCategory() != null && !"".equals(specialCertificate.getWorkCategory())){
                    myCertificateInfo.setWorkCategory(specialCertificate.getWorkCategory());
                }
                //设置作业项目
                if (specialCertificate.getWorkProject() != null && !"".equals(specialCertificate.getWorkProject())){
                    myCertificateInfo.setWorkProject(specialCertificate.getWorkProject());
                }
                //设置证书编号
                if (specialCertificate.getCertificateNo() != null && !"".equals(specialCertificate.getCertificateNo())){
                    myCertificateInfo.setCertificateNo(specialCertificate.getCertificateNo());
                }
                //设置发证单位
                if (specialCertificate.getIssuingAuthority() != null && !"".equals(specialCertificate.getIssuingAuthority())){
                    myCertificateInfo.setIssuingAuthority(specialCertificate.getIssuingAuthority());
                }
                //设置发证时间
                if (specialCertificate.getFirstIssueDate() != null){
                    myCertificateInfo.setDigitalIssueTime(specialCertificate.getFirstIssueDate());
                }
                //设置有效期起
                if (specialCertificate.getValidityStartTime() != null){
                    myCertificateInfo.setValidityStart(specialCertificate.getValidityStartTime());
                }
                //设置有效期止
                if (specialCertificate.getValidityEndTime() != null){
                    myCertificateInfo.setValidityEnd(specialCertificate.getValidityEndTime());
                }
                //设置纸质证书领取方式-默认现场-1
                myCertificateInfo.setReceiveMethod("1");
//                if (specialCertificate.getReceiveMethod() != null && !"".equals(specialCertificate.getReceiveMethod())){
//                    myCertificateInfo.setReceiveMethod(specialCertificate.getReceiveMethod());
//                }
//                //设置快递单号
//                if (certificateIssue.getTrackingNo() != null && !"".equals(certificateIssue.getTrackingNo())){
//                    myCertificateInfo.setTrackingNo(certificateIssue.getTrackingNo());
//                }
                myCertificateInfoList.add(myCertificateInfo);
            }
        }
        return myCertificateInfoList;
    }
}
